package com.inight.nightoj.judge.codesandbox;

import com.inight.nightoj.judge.codesandbox.CodeSandbox;
import com.inight.nightoj.judge.codesandbox.impl.ExampleCodeSandbox;
import com.inight.nightoj.judge.codesandbox.impl.RemoteCodeSandbox;
import com.inight.nightoj.judge.codesandbox.impl.ThirdPartyCodeSandbox;


/**
 * 通过最简单的工厂模式, 根据传入的字符串来创建对应的代码沙箱
 * 没有用到抽象工厂
 */
public class CodeSandboxFactory {

    public static CodeSandbox newInstance(String type) {
        switch (type) {
            case "example":
                return new ExampleCodeSandbox();
            case "remote":
                return new RemoteCodeSandbox();
            case "thirdParty":
                return new ThirdPartyCodeSandbox();
            default:
                return new ExampleCodeSandbox();
        }
    }


}
